package com.pengtu.gsj.dao.system;
import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.pengtu.gsj.dao.hibernate.HibernateDao;
import com.pengtu.gsj.entity.app.Organization;

/** 
 * @author zl 
 * @version 创建时间：2017年4月6日 下午3:25:11 
 * 类说明 
 */
@Repository
public class OrganizationDao  extends HibernateDao<Organization, String>{

	@SuppressWarnings("unchecked")
	public List<Organization> getAllJu() {
		String hql =" from Organization m where m.orgNum like '%4403%' and  m.orgForm ='2'  and m.orgName like '%局%' and m.delFlag='0' order by m.orgNum ASC";
		List<Organization> list =this.createQuery(hql).list();
		if(list==null||list.size()==0){
			return new ArrayList<Organization>();
		}
		return list;
	}
	/**
	 * deleteAll:
	 * 适用: 
	 * @exception 
	 * @since  1.0.0
	*/
	public void deleteAll() {
		String hql = "delete Organization c";
		this.getSession().createQuery(hql).executeUpdate();
	}
	
	/**
	 *  
	 * findByParentIds:找子节点
	 * 适用:新增修改页面
	 * @param id
	 * @return 所有节点
	 * @exception 
	 * @since  1.0.0
	 */
	public List<Organization> findByParentIds(String id) {
		String hql = "from Organization m where m.parentIds like ?";
		return this.find(hql, "%"+id+"%");
	}
	
	/**
	 * 
	 * findTop:
	 * 适用:顶级节点
	 * @return 
	 * @exception 
	 * @since  1.0.0
	 */
	public Organization findTop() {
		String hql = "from Organization m where m.parentIds='0' and m.delFlag='0'";
		return this.findUnique(hql);
	}
}
